<?php

class m_jurusan extends CI_Model {

    function __construct() {
        // Call the Model constructor
        parent::__construct();
    }

    // get data jurusan
    function get_data_jurusan() {
        $sql = "SELECT * FROM jurusan";
        $query = $this->db->query($sql);
        if ($query->num_rows() > 0) {
            $result = $query->result_array();
            $query->free_result();
            return $result;
        } else {
            return array();
        }
    }

    // get detail data jurusan
    function get_detail_data_jurusan($params) {
        $sql = "SELECT * FROM jurusan WHERE jurusan_kd = ?";
        $query = $this->db->query($sql, $params);
        if ($query->num_rows() > 0) {
            $result = $query->row_array();
            $query->free_result();
            return $result;
        } else {
            return array();
        }
    }

    // insert data jurusan
    function insert_data_jurusan($params) {
        $sql = "INSERT INTO jurusan (jurusan_nm, jurusan_alias, mdb, mdd) 
            VALUES(?, ?, ?, NOW())";
        return $this->db->query($sql, $params);
    }

    // update data jurusan
    function update_data_jurusan($params) {
        $sql = "UPDATE jurusan SET jurusan_nm = ?, jurusan_alias = ?, mdb = ?, mdd = NOW() 
            WHERE jurusan_kd = ?";
        return $this->db->query($sql, $params);
    }

    // hapus data jurusan
    function delete_data_jurusan($params) {
        $sql = "DELETE FROM jurusan WHERE jurusan_kd = ?";
        return $this->db->query($sql, $params);
    }

}